<template>
	<el-main>
		<el-form>
			<el-form-item label="发件人">
				<div style="width: 100%;">
					<el-avatar :src="form.avatar" size="small" style="margin-top: 5px;"></el-avatar>
					<span style="position: absolute;margin-left: 15px">{{ form.fromUserName }}</span>
					<span style="float: right">
								<div>
									<el-icon style="margin-right: 10px;"><el-icon-clock/></el-icon>{{ form.sendTime }}
								</div>
							</span>
				</div>
			</el-form-item>
			<el-form-item label="邮件标题">
				<span style="font-weight: 600;font-size: 16px">{{ form.subject }}</span>
			</el-form-item>
			<el-form-item label="邮件内容">
				<div v-html="form.content"></div>
			</el-form-item>
			<el-form-item label="邮件附件" v-if="form.attachId!=''">
				<attach-menu :attachIds="form.attachId" :roleFlag="1" :preview="true"></attach-menu>
			</el-form-item>
		</el-form>
	</el-main>
</template>

<script>
import AttachMenu from '@/views/module/attachMenu'

export default {
	name: 'Email Details',
	components: {
		AttachMenu,
	},
	data() {
		return {
			form: {
				emailId: this.$route.query.emailId,
				subject: "",
				content: "",
				attachId: "",
				fromUserName: "",
				avatar: "",
				sendTime: ""
			},
		}
	},
	mounted() {
		this.getMyEmailById();
	},
	methods: {
		async getMyEmailById() {
			let res = await this.$API.email.getMyEmailById.get({emailId: this.form.emailId});
			{
				if (res.code == 200) {
					this.form.subject = res.data.subject
					this.form.content = res.data.content
					this.form.attachId = res.data.attachId
					this.form.fromUserName = res.data.fromUserName
					this.form.avatar = res.data.avatar
					this.form.sendTime = res.data.sendTime
					//this.setEmailReadStatus(data);
				} else {
					this.$alert(res.message, "提示", {type: 'error'})
				}
			}
		}

	}

}
</script>

<style>
</style>
